﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>

    <script type="text/javascript">
 
    $(document).ready(function(){

    
        $.ajax({
            type: "POST",
            url: "PageMethods.aspx/AddNumbers",
            data: "{ Num1: 9, Num2: 3 }",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function(msg) {
                GotMessage(msg);
            },
            error: function(jqXHR, textStatus, errorThrown) { alert(errorThrown)}
            
        });
    
    });
    
    function GotMessage(msg)
    {
         alert(msg.d.TheAnswer);
    }
    
    </script>

</head>
<body>
    <form id="form1" runat="server">
    
    <!-- Note: When we use JQuery to call the PageMethod, this ScriptManager is probably not even necessary -->
    <asp:ScriptManager ID="scriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    
    <div>
    </div>
    </form>
</body>
</html>
